#include "Timestamp.h"

#include <ctime>

Timestamp::Timestamp()
    : time_(0)
{
}

Timestamp::Timestamp(int64_t time)
    : time_(time)
{
}

Timestamp Timestamp::now()
{
    return Timestamp(time(NULL));
}

std::string Timestamp::toString() const
{
    struct tm *now_time = localtime(&time_);
    char buf[128];
    snprintf(buf, sizeof(buf), "%4d/%02d/%02d-%02d:%02d:%02d",
             now_time->tm_year + 1900, now_time->tm_mon + 1, now_time->tm_mday,
             now_time->tm_hour, now_time->tm_min, now_time->tm_sec);
    return buf;
}
